#include "Vec2d.h"

Vec2d::Vec2d()
{
	this->x = 0.0f;
	this->y = 0.0f;
}

Vec2d::Vec2d(float x, float y)
{
	this->x = x;
	this->y = y;
}

Vec2d Vec2d::operator+(const Vec2d &other) const
{
	Vec2d sum(this->x + other.x, this->y + other.y);
	return sum;
}

Vec2d Vec2d::operator-(const Vec2d &other) const
{
	return Vec2d(this->x - other.x, this->y - other.y);
}

float Vec2d::operator*(const Vec2d &other) const
{
	return ((this->x * other.x) + (this->y * other.y));
}

Vec2d Vec2d::operator*(const float &scalar) const
{
	return Vec2d(this->x * scalar, this->y * scalar);
}

Vec2d Vec2d::normalize()
{
	float factor = invSqrt((this->x * this->x) + (this->y * this->y));
	return Vec2d(this->x * factor, this->y * factor);
}

Vec2d Vec2d::normalizePrecise()
{
	float factor = invSqrtPrecise((this->x * this->x) + (this->y * this->y));
	return Vec2d(this->x * factor, this->y * factor);
}
	



